M.filter_references={
    Y : null,
    transaction : [],
    init_ref_form : function(Y, link) {
        this.Y = Y;
        //This script will update calendar links based on form selection
        //means user doesn't need to submit page to get updated links

        //First check for selection form and ready state
        Y.on('contentready', function () {
            //Add update event to every radio button in form
            Y.on('click', refexport, '.reference_filter_item input[type=button]');
        }, 'body');

        var refexport = function(sub) {
            var idnum = this.get('id').substr(6);

            var but_selection = Y.one('#refselect_' + idnum);
            if (but_selection == 'null') {
                return;
            }
            var selected = but_selection.get('value');
            if (selected == 'null') {
                return;
            }
            //dynamically make form to submit
            var formy = Y.one('#ref_form_' + idnum);
            if (!formy) {
                var formtag = '<form method="post" action="' + link + '" style="display:none" ';
                formtag += 'id="ref_form_' + idnum + '">';
                formtag += '<input type="hidden" name="button" value="' + selected + '"/>';

                formtag += M.filter_references.outerhtml(Y.Node.getDOMNode(Y.one('#info_' + idnum)));
                formtag += M.filter_references.outerhtml(Y.Node.getDOMNode(Y.one('#xml_' + idnum)));
                Y.one('body').append(formtag);
            } else {
                var buttontag = Y.one('#ref_form_' + idnum + ' input[name=button]');
                buttontag.set('value', selected);
            }
            formy = Y.one('#ref_form_' + idnum);
            formy.submit();
            return;
        };
    },
    outerhtml : function (node) {
        // if IE, Chrome take the internal method otherwise build one
        return node.outerHTML || (
            function(n){
                var div = document.createElement('div'), h;
                div.appendChild( n.cloneNode(true) );
                h = div.innerHTML;
                div = null;
                return h;
            })(node);
        }
};
